package ms.unicorn.diagram.figures;

import ms.unicorn.dsl.IFigureEx;
import ms.unicorn.dsl.ITheme;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.swt.graphics.Image;

public class LabelFigure extends WrappingLabel implements IFigureEx {

	private String name;
	private int flag;
	private ITheme theme;
	private boolean autoVisible;
	private Image labelIcon;

	public LabelFigure(String name) {
		this.name = name;
	}

	public LabelFigure(String name, String text) {
		super(text);
		this.name = name;
	}

	public LabelFigure(String name, Image image) {
		super(image);
		this.name = name;
	}

	public LabelFigure(String name, String text, Image image) {
		super(text, image);
		this.name = name;
	}

	@Override
	public void paint(Graphics graphics) {
		super.paint(graphics);
	}

	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public int getFlag() {
		return this.flag;
	}

	@Override
	public void setFlag(int flag) {
		this.flag = flag;
	}

	@Override
	public ITheme getTheme() {
		return this.theme;
	}

	@Override
	public void setTheme(ITheme theme) {
		this.theme = theme;
	}
	
	public boolean getTextWrap() {
		return super.isTextWrapOn();
	}
	
	public boolean getAutoVisible() {
		return this.autoVisible;
	}
	
	public void setAutoVisible(boolean value) {
		this.autoVisible = value;
	}
	
	@Override
	public boolean isVisible() {
		return super.isVisible() && (!autoVisible || this.getText().length() > 0);
	}
	
	@Override
	public void setIcon(Image image) {
		super.setIcon(image);
	}

	public Image getLabelIcon() {
		return labelIcon;
	}

	public void setLabelIcon(Image labelIcon) {
		this.labelIcon = labelIcon;
	}
}
